package demoMod.nanaki.cards.nanaki;

import com.megacrit.cardcrawl.actions.common.HealAction;
import com.megacrit.cardcrawl.actions.common.LoseHPAction;
import com.megacrit.cardcrawl.characters.AbstractPlayer;
import com.megacrit.cardcrawl.core.CardCrawlGame;
import com.megacrit.cardcrawl.localization.CardStrings;
import com.megacrit.cardcrawl.monsters.AbstractMonster;
import com.megacrit.cardcrawl.powers.AbstractPower;
import demoMod.nanaki.NanakiMod;
import demoMod.nanaki.powers.NotePower;

public class SpiritualCake extends AbstractNanakiCard {
    public static final String ID = NanakiMod.makeID("SpiritualCake");

    private static final CardStrings cardStrings = CardCrawlGame.languagePack.getCardStrings(ID);
    public static final String NAME = cardStrings.NAME;
    public static final String DESCRIPTION = cardStrings.DESCRIPTION;
    public static final String IMG_PATH = "cards/SpiritualCake";

    private static final CardType TYPE = CardType.SKILL;
    private static final CardRarity RARITY = CardRarity.RARE;
    private static final CardTarget TARGET = CardTarget.ENEMY;

    private static final int COST = 5;

    public SpiritualCake() {
        super(ID, NAME, NanakiMod.getResourcePath(IMG_PATH), COST, DESCRIPTION, TYPE, RARITY, TARGET);
        this.baseMagicNumber = this.magicNumber = 4;
        this.exhaust = true;
        this.tags.add(CardTags.HEALING);
    }

    @Override
    public Runnable getUpgradeAction() {
        return () -> upgradeMagicNumber(-1);
    }

    @Override
    public void use(AbstractPlayer p, AbstractMonster m) {
        addToBot(new LoseHPAction(p, p, this.magicNumber));
        if (m != null && !m.isDeadOrEscaped()){
            if (m.hasPower(NotePower.POWER_ID)) {
                AbstractPower note = m.getPower(NotePower.POWER_ID);
                addToBot(new HealAction(p, p, note.amount));
            }
        }
    }
}
